﻿
using System;
using System.Globalization;
using System.Reflection;

namespace Xacml.Core
{
  internal class Resource
  {
    private static Resource InternalResource = new Resource();
    private System.Resources.ResourceManager _rm = (System.Resources.ResourceManager) null;
    private const string ResourceFileName = ".Messages";

    public static Resource ResourceManager
    {
      get
      {
        return Resource.InternalResource;
      }
    }

    public string this[Resource.MessageKey key]
    {
      get
      {
        return this._rm.GetString(key.ToString((IFormatProvider) CultureInfo.InvariantCulture), CultureInfo.CurrentUICulture);
      }
    }

    public string this[Resource.MessageKey key, params object[] parameters]
    {
      get
      {
        return this.FormatMessage(key, parameters);
      }
    }

    private Resource()
    {
      this._rm = new System.Resources.ResourceManager(this.GetType().Namespace + ".Messages", Assembly.GetExecutingAssembly());
    }

    public string FormatMessage(Resource.MessageKey key, params object[] format)
    {
      return string.Format((IFormatProvider) CultureInfo.CurrentUICulture, this[key], format);
    }

    public enum MessageKey
    {
      exc_invalid_collection_type,
      exc_invalid_node_name,
      exc_duplicated_policy_in_repository,
      exc_invalid_datatype_in_stringvalue,
      exc_invalid_uri_schema,
      exc_bug,
      exc_invalid_daytime_duration_value,
      exc_invalid_yearmonth_duration_value,
      exc_unsupported_xpath_version,
      exc_configuration_file_not_found,
      exc_invalid_attribute_designator,
      exc_invalid_function_usage,
      exc_type_mismatch,
      exc_policy_reference_not_resolved,
      exc_policyset_reference_not_resolved,
      exc_invalid_version_parameter_value,
      exc_invalid_stream_parameter_canseek,
      exc_invalid_document_format_no_policyorpolicyset,
    }
  }
}
